package database.helpers;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class Feedback_Table {

public databas_helper dbHelper;	
public SQLiteDatabase database;
	/**
	 * Assignment table related constants.
	 */
	public final static String FEEDBACK_TABLE="FEEDBACK";	
	public final static String FEEDBACK_CARINGFRIEND="CARINGFRIEND";
	public final static String FEEDBACK_MSG="MSG";			
	public final static String FEEDBACK_ID="_id";
	
	public Feedback_Table(Context context){
		dbHelper = new databas_helper(context);
		database = dbHelper.getWritableDatabase();
	}
	public Feedback_Table(databas_helper dbHelper,SQLiteDatabase database){
		this.dbHelper = dbHelper;
		this.database = database;
	}
	
	/**\
	 * Creates a new Adminstrator
	 	 */
	public long addAdminstrator(String CARINGFRIEND,String MSG){
		ContentValues values = new ContentValues();
		values.put(FEEDBACK_CARINGFRIEND,CARINGFRIEND);
		values.put(FEEDBACK_MSG,MSG);	

		return database.insert(FEEDBACK_TABLE, null, values);
	}	
	
	public void close() {
		dbHelper.close();
	}
	/**
	 * Fetch all Adminstrators
	 * @return
	 */
	public Cursor getAllAdminstrators(){
		Cursor mCursor = database.query(true, FEEDBACK_TABLE, new String[]
				{
				FEEDBACK_ID,FEEDBACK_CARINGFRIEND,FEEDBACK_MSG},null
				, null, null, null, null, null);
		if (mCursor != null) {
			mCursor.moveToFirst();
		}
		return mCursor;
	}
	/**
	 * 
	 */
	public int editAdminstrator(String CARINGFRIEND,String MSG){
		ContentValues values = new ContentValues();
		values.put(FEEDBACK_CARINGFRIEND,CARINGFRIEND);
		values.put(FEEDBACK_MSG,MSG);
		
		return database.update(FEEDBACK_TABLE, values,FEEDBACK_ID + "=?",new String[]{CARINGFRIEND});
	}
	
	public boolean delete(String CARINGFRIEND){
		return database.delete(FEEDBACK_TABLE, FEEDBACK_ID + "=" + CARINGFRIEND, null) > 0;
	}
}
